<?php

namespace app\command;

use app\service\DnService;
use app\model\PhoneDn;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class DnInitCommand extends Command
{
    protected static $defaultName = 'dn:init';

    protected function execute(InputInterface $input, OutputInterface $output)
    {
        // 查询数据库所有已绑定分机号
        $usedDns = PhoneDn::column('dn');

        // 传入已用分机号，初始化号池
        $count = DnService::initPool($usedDns);

        $output->writeln("初始化成功，分机号可用数量：$count");
        return self::SUCCESS;
    }
}
